package com.situ.mall.service.impl;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.situ.mall.common.ServerResponse;
import com.situ.mall.dao.UserMapper;
import com.situ.mall.entity.User;
import com.situ.mall.service.IUserService;

@Service
public class UserServiceImpl implements IUserService{
	@Autowired
	private UserMapper userMapper;

	@Override
	public ServerResponse login(String username, String password, HttpSession session) {
		//if ("lisi".equals(name)) {
		//	return ServerResponse.createError("用户名不存在");
		//}
		
		User user = userMapper.login(username, password);
		if (user == null) {
			return ServerResponse.createError("密码错误");
		}
		session.setAttribute("user", user);
		return ServerResponse.createSuccess("登录成功", user);
	}

}
